package bTree.LeetCode;

import java.util.HashMap;

public class 机器人能否返回原点 {
    public boolean judgeCircle(String moves) {
        HashMap<Character,Integer>hashMap=new HashMap<>();
        hashMap.put('R',100);
        hashMap.put('L',-100);
        hashMap.put('U',-1);
        hashMap.put('D',1);
        int sum=0;
        for (int i = 0; i < moves.length(); i++) {
            sum+=hashMap.get(moves.charAt(i));
        }
        if(sum==0){
            return true;
        }
        return false;
    }
}